/*
 * EndOfProtocolMessage.java    0.0.1    28/dic/2009
 * 
 * Copyright (c) 2009 mentalsmash.org
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * The use of the Apache License does not indicate that this project is
 * affiliated with the Apache Software Foundation.
 */ 
package org.mentalsmash.tazio.transparency.commons.messages;

import java.io.Serializable;

import org.mentalsmash.tazio.net.cs.MessageOutputStream;
import org.mentalsmash.tazio.transparency.impl.ProtocolHandler;
import org.mentalsmash.tazio.transparency.interfaces.InputMessageListener;
import org.mentalsmash.tazio.transparency.interfaces.MessageFilter;

/**
 * This message is used to encapsulate a <code>null</code> return value from the 
 * {@link MessageFilter}.
 * <p>
 * This is done because if the {@link ProtocolHandler} would write a <code>null</code>
 * value on the {@link MessageOutputStream} as a result of the computation of an answer 
 * it would corrupt the stream and cause an exception to be thrown.
 * </p>
 * <p>
 * Problems like this one could happen if the upper layers end some kind of protocol 
 * returning a <code>null</code> result (from this example comes the name of this class) or 
 * if no {@link InputMessageListener} was register for a message type, resulting in the 
 * returning of a <code>null</code> value from the {@link MessageFilter}. 
 * </p>
 * <p>
 * This type of message is used only for safety reasons, thus its fields are set to null and 
 * it has no background logic, it simply "assigns" a safe type to <code>null</code> return 
 * values.
 * </p>
 * 
 * @version 0.0.1	28/dic/2009
 * @author Enrico Savioli <savioli.enrico@gmail.com>
 */
public class EndOfProtocolMessage implements TazioMessage {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8413993254077610682L;

	/* (non-Javadoc)
	 * @see org.mentalsmash.tazio.transparency.commons.messages.TazioMessage#getMsgID()
	 */
	@Override
	public TazioMessageID getMsgID() {
		
		return null;
		
	}

	/* (non-Javadoc)
	 * @see org.mentalsmash.tazio.transparency.commons.messages.TazioMessage#getPayload()
	 */
	@Override
	public Serializable getPayload() {
		
		return "EndOfProtocolMessage";
		
	}

}
